<?php

namespace app\order\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;

use think\facade\Log;

class Settlement extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('Settlement');
        // 设置参数
    }
    protected function execute(Input $input, Output $output)
    {
        Log::info('------执行结算开始------');
        set_time_limit(0);
        //加进程锁
        $locKey = "lock_order_settlement" ;
        $redis = \app\common\model\Redis::handler();
        $lock = $redis->get($locKey);
        if ($lock) return false;
        try {
            \think\facade\Hook::exec([\app\order\event\Settlement::class,"run"]);  
        } catch (\Exception $e) { 
            Log::error($e->getMessage());
        }finally{
            $redis->del($locKey);
        }      
        Log::info('------执行结算结束------');
    }
   
}
